<template>
  <div class="box-body">
    <ul>
      <li v-for="(item, index) in listData" :key="item.id">
        <span>{{ index + 1 }}</span>
        <span>{{ item.name }}</span>
        <button @click="del(item.id)" class="btn-del">X</button>
      </li>
    </ul>
  </div>
</template>
<script >
export default {
  data() {
    return {};
  },
  props: {
    listData: Array,
  },
  components: {},
  created() {},
  mounted() {},
  methods: {
    del(id) {
      this.$emit("del", id);
    },
  },
};
</script>
<style lang='less' scoped>
.box-body {
  margin-bottom: 20px;

  ul {
    list-style: none;

    li {
      position: relative;
      color: #ccc;
      height: 40px;
      line-height: 40px;
      border-bottom: 1px solid #000;

      span {
        margin-right: 40px;
      }

      button {
        font-size: 18px;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 20px;
        background-color: #fff;
        outline: none;
        border: none;
        opacity: 0;
        transition: all 0.5s;
      }

      button:hover {
        opacity: 1;
      }
    }
  }
}
</style>